package com.probiz.estore.common.service;

import java.math.BigDecimal;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.probiz.estore.common.model.cart.Shoppingcart;
import com.probiz.estore.common.model.order.CheckoutSession;
import com.probiz.estore.common.model.order.SalesOrder;
import com.probiz.estore.common.model.sales.GiftCertificate;
import com.probiz.estore.common.model.system.PaymentMethod;
import com.probiz.estore.common.model.system.SelfCollectionCentre;
import com.probiz.estore.common.model.system.ShippingMethod;
import com.probiz.estore.common.model.system.ShippingRate;
import com.probiz.estore.common.model.system.Wrap;
import com.probiz.estore.exception.CheckoutException;
import com.probiz.estore.exception.GiftCertificateStateException;
import com.probiz.estore.exception.OrderProccessFlowException;
import com.probiz.estore.exception.OutOfStockException;
import com.probiz.estore.exception.ShopPointConsumptionException;

public interface CheckoutService {
	/**
	 * 根据提供的支付方式、地区id，返回所有满足条件的运输方式
	 * @param isCod 是否支持货到付款。cod = cash on delivery 货到付款
	 * @return
	 */
	public List<ShippingRate> getRegionShippingRates(Boolean isCod, Integer regionId);
	/**
	 * 根据运输费率id获得运输费率
	 * @param id
	 * @return
	 */
	public ShippingRate getShippingRateById(Integer id);
	
	/**
	 * 根据费率的id和商品重量，返回运输费用
	 * @param Integer 费率id(ShippingRate.shippingRateId)
	 * @param weight 商品重量
	 * @return
	 */
	public BigDecimal getShippingExpence(Integer shippingRateId,BigDecimal weight);
	
	
	/**
	 * 获得地区的提货中心
	 * @param regionId
	 * @return
	 */
	public List<SelfCollectionCentre> getSelfCollectionCentreListByRegionId(Integer regionId);
	/**
	 * 根据提货中心id获得提货中心实体
	 * @param selfCollectionCentreId
	 * @return
	 */
	public SelfCollectionCentre getSelfCollectionCentreById(Integer selfCollectionCentreId);
	
	/**
	 * 查询所有当前系统定义有的包装方式
	 * @return
	 */
	public List<Wrap> getSystemWraps();
	
	public Wrap getWrapById(Integer wrapId);
	
	public void caculateTaxes(Shoppingcart shoppingcart,Integer regionId);
	
	//是否需要计税
	public boolean isTaxEnabled();
	
	public GiftCertificate getGiftCertificateByNo(String no);
	
	public PaymentMethod getPaymentMethodById(Integer paymentMethodId);
	
	public ShippingMethod getShippingMethodById(Integer shippingMethodId);
	
	public List<ShippingMethod> getShippingMethodList();

	/**
	 * 下订单
	 * @param checkoutSession 填写结账信息的数据
	 * @throws OutOfStockException
	 * @throws GiftCertificateStateException
	 * @throws ShopPointConsumptionException
	 */
	public SalesOrder doPlaceOrder(CheckoutSession checkoutSession)	throws OutOfStockException, GiftCertificateStateException, ShopPointConsumptionException,CheckoutException;
	
	
	/**
	 * 后台编辑订单保存
	 * @param salesOrder
	 * @param checkoutSession
	 * @throws OrderProccessFlowException
	 */
	public void doEditOrder(SalesOrder salesOrder,CheckoutSession checkoutSession) throws OutOfStockException, GiftCertificateStateException, ShopPointConsumptionException,OrderProccessFlowException,CheckoutException;

	/**
	 * 验证购物车数据是否被删除
	 * 
	 * */
	public Shoppingcart validationDeleted(HttpServletRequest request,
			HttpServletResponse response, Shoppingcart shoppingcart);
	
}
